package com.ruan.common;

/**
 * 基于ThredLocal封装工具类，用于保存和获取当前用户登录id
 */

public class BaseContext {

    private BaseContext(){

    }

    private static final ThreadLocal<Long> threadLocal=new ThreadLocal<>();


   //清除用户信息
    public static void clear(){
        threadLocal.remove();
    }


    //存储用户id
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }


    //获取当前用户id
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
